package com.itheima.demo3;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Function;

public class FunctionDemo3 {
    public static void main(String[] args) {

        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student ("张三丰",100);
        Student s2 = new Student ("张无忌",28);
        Student s3 = new Student ("李白",26);
        Collections.addAll(list,s1,s2,s3);

        String[] strings = list.stream().map(new FunctionDemo3()::student).toArray(String[]::new);
        System.out.println(Arrays.toString(strings));

    }

    public String student(Student student){
        StringBuilder s = new StringBuilder();
        s.append(student.name +"-"+student.age);
        return s.toString();
    }
}
